const { defineConfig } = require("@vue/cli-service");
module.exports = defineConfig({
  transpileDependencies: true,

  // 开发服务器配置
  devServer: {
    port: 8082, // 前端端口
    open: true, // 自动打开浏览器
    allowedHosts: "all",
    proxy: {
      "/api": {
        target: "http://localhost:8080", // 后端API地址
        ws: true,
        changeOrigin: true,
        secure: false,
        pathRewrite: {
          "^/api": "",
        },
        onError: function (err, _req, _res) {
          console.log("代理错误:", err);
        },
        logLevel: "debug",
      },
    },
  },

  // 配置路径别名
  configureWebpack: {
    resolve: {
      alias: {
        "@": require("path").resolve(__dirname, "src"),
      },
    },
    plugins: [
      new (require("webpack").DefinePlugin)({
        __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false,
        __VUE_OPTIONS_API__: true,
        __VUE_PROD_DEVTOOLS__: false,
      }),
    ],
  },
});
